-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] OWPredictions: Allow classification when data has no target column #2183
Conversation
@lanzagar Could you please just check the code as well and merge. I only tested it on cases and it works. |
|
||
def _update_predictions_model(self): | ||
"""Update the prediction view model.""" | ||
if self.data is not None: | ||
if self.data is not None and self.class_var is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the second part (class_var not None) also imply the first (data not None).
(The same if
appears in a couple of places)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.class_var
comes from predictors and can be not None
even if no data is present. See https://github.com/janezd/orange3/blob/21ba4679bf19efde4498363a56c69bf3798ea0f9/Orange/widgets/evaluate/owpredictions.py#L224.
newmetas, newcolumns = self._classification_output_columns() | ||
else: | ||
newmetas, newcolumns = self._regression_output_columns() | ||
|
||
attrs = list(self.data.domain.attributes) if self.output_attrs else [] | ||
metas = list(self.data.domain.metas) + newmetas | ||
domain = Orange.data.Domain(attrs, class_var, metas=metas) | ||
domain = \ | ||
Orange.data.Domain(attrs, self.data.domain.class_var, metas=metas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we assure at the beginning that self.data.domain.class_var
must be equal to self.class_var
, then the second (shorter/direct) version would look nicer here. And the line break would probably not be necessary :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I recalled: I did have self.class_var
and it fit into a single line. But this fails exactly in the case that this PR is fixing: if self.data.domain.class_var
is None
, the output data should have no class, either. Changing this to self.class_var
can add a column of unknown values if the original data has no class.
Issue
OWPredictions
reported mismatching targets if the data had not target column (#2148).This occurred because the data's
class_var
wasNone
, and it was thus not the same as the target of predictors.Description of changes
The widget's
self.class_var
is now set from the target of the models. All models must have the same target. Also, if the data has a target, it has to be the same as the models' target.This required several other changes in the widget to cope with situations that could not occur previously.
Includes